package com.cdeledu.不可重入锁和可重入锁.不可重入锁;

// 当调用print()方法时，获得了锁，这时就无法再调用doAdd()方法，这时必须先释放锁才能调用，所以称这种锁为不可重入锁
public class Count {

	Lock lock = new Lock();
	public void print() throws InterruptedException{
		lock.lock();
		doAdd();
		lock.unlock();
	}
	public void doAdd() throws InterruptedException{
		lock.lock();
		System.out.println("进入了doAdd方法");
		lock.unlock();
	}

	public static void main(String[] args) throws InterruptedException {
		Count c = new Count();
		c.print();
	}

}
